package com.liliudong.template.common.security;

import com.liliudong.template.common.entity.sys.SysUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 当前登录用户
 *
 * @author liudo
 * @version 1.0
 * @project template-backend
 * @date 2024/7/30 15:17:54
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CurrentUser {

    public static CurrentUser of(SysUser sysUser) {
        CurrentUser currentUser = new CurrentUser();
        currentUser.setId(sysUser.getId());
        currentUser.setUsername(sysUser.getUsername());
        currentUser.setDeptNo(sysUser.getDeptNo());
        currentUser.setCreatedBy(sysUser.getCreatedBy());
        currentUser.setCreatedFrom(sysUser.getCreatedFrom());
        return currentUser;
    }

    /**
     * 用户ID
     */
    private Long id;

    /**
     * 用户名
     */
    private String username;

    /**
     * 部门id
     */
    private String deptNo;

    /**
     * 创建人
     */
    private Long createdBy;

    /**
     * 创建自部门编号
     */
    private String createdFrom;
}
